'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _radium = require('radium');

var _radium2 = _interopRequireDefault(_radium);

var _LoginPic = require('./LoginPic');

var _LoginPic2 = _interopRequireDefault(_LoginPic);

var _LoginForm = require('./LoginForm');

var _LoginForm2 = _interopRequireDefault(_LoginForm);

var _lightbiFrontProject = require('lightbi-front-project');

var _lightbiFrontUtils = require('lightbi-front-utils');

var _lightbiFrontWidget = require('lightbi-front-widget');

var _IndexHeader = require('../common/IndexHeader');

var _IndexHeader2 = _interopRequireDefault(_IndexHeader);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var LoginView = (0, _radium2.default)(_class = function (_React$Component) {
  _inherits(LoginView, _React$Component);

  function LoginView(props) {
    _classCallCheck(this, LoginView);

    var _this = _possibleConstructorReturn(this, (LoginView.__proto__ || Object.getPrototypeOf(LoginView)).call(this, props));

    _this.state = { isLoading: true };
    _this.jumpUri = _this.props.location.query['jumpUri'];
    return _this;
  }

  _createClass(LoginView, [{
    key: 'componentDidMount',
    value: function componentDidMount() {
      if (_lightbiFrontProject.LoginValidate.isLogin(this.props.location.query)) {
        if (_lightbiFrontUtils.LoginInfo.getIsAdmin()) {
          if (this.jumpUri == null || this.jumpUri.length == 0) (0, _lightbiFrontUtils.Goto)('/admin/projects', this.context.router);else (0, _lightbiFrontUtils.Goto)(_lightbiFrontUtils.Base64.decode(this.jumpUri), this.context.router);
        } else this.setState({ isLoading: false });
      } else this.setState({ isLoading: false });
    }
  }, {
    key: 'render',
    value: function render() {
      if (this.state.isLoading) return _react2.default.createElement(
        'div',
        { className: 'no-user-select', style: { height: '100%', width: '100%', position: 'relative' } },
        _react2.default.createElement(_lightbiFrontWidget.WaitView, { isShow: true, type: _lightbiFrontWidget.WaitView.SPIN })
      );else return _react2.default.createElement(
        'div',
        { className: 'no-user-select', style: { height: '100%', width: '100%', position: 'relative' } },
        _react2.default.createElement(_IndexHeader2.default, { router: this.context.router, selectedItem: '\u767B\u5F55', location: this.props.location }),
        _react2.default.createElement(
          'div',
          { style: { position: 'relative', width: '100%', textAlign: 'center' } },
          _react2.default.createElement(_LoginForm2.default, { router: this.context.router, location: this.props.location })
        )
      );
    }
  }]);

  return LoginView;
}(_react2.default.Component)) || _class;

;

LoginView.contextTypes = {
  router: _react2.default.PropTypes.object.isRequired
};

module.exports = LoginView;